<?php

class MY_Controller extends Controller {

    var $_data = FALSE;
    var $container = "container";

    function MY_Controller() {
        parent::Controller();
        $this->load->helper('form');
        $this->load->helper('url');
        $this->load->helper('doggy_flirt_helper');
        $this->load->library('pagination');
        $this->load->library('session');
        $this->load->library('form_validation');
        $this->_data['error'] ='';
        $this->_data['date_erreur'] =FALSE;
        $this->_data['validate_erreur'] =FALSE;
    }

    function display_view($path) {
        $this->before_render();
        $this->_data['view_path'] = $path;
        $this->load->view($this->container, $this->_data);
    }
    function before_render(){
        
    }
}

class Doggy_Flirt_FrontEnd_Controller extends MY_Controller {
    function Doggy_Flirt_FrontEnd_Controller() {
        parent::MY_Controller();
        $this->load->library('cart');
        $this->load->model('Friend_m');
        $this->load->model('Home_m');
        $this->load->model('Message_m');
        $this->_data['account_id'] = $this->session->userdata('doogy.id')?$this->session->userdata('doogy.id'):0;
         $this->_data['avatar'] = $this->session->userdata('avatar');
        $this->_data['account_name'] = $this->session->userdata('account_name');
        $header['page'] = "home/header";
        $footer['page'] = "home/footer";
        $sidebar['page'] = $this->_data['account_id']==NULL?"home/sidebar":"home/friend_sidebar";
        $this->_data['sidebar'] = $sidebar;
        $this->_data['footer'] = $footer;
        $this->_data['header'] = $header;
        $this->_data['selected_race'] = '';
        $this->_data['selected_region'] = '';
        $this->_data['selected_sex'] = '';
    }
     function  before_render() {
        $this->_data['not_friends'] = $this->Friend_m->list_random_account($this->_data['account_id'],6,0);
        $this->_data['request_friends'] = $this->Friend_m->list_friend_request($this->_data['account_id'],6,0);
        $this->_data['friends'] = $this->Friend_m->get_friends($this->_data['account_id'],6,0);         
        $this->_data['total_unread']= $this->Message_m->count_unread_messages($this->_data['account_id']);
        $this->_data['total_unread_reply']= $this->Message_m->count_unread_reply($this->_data['account_id']);
        $this->_data['list_horoscope'] = $this->Home_m->get_random_horoscope();
        $this->_data['list_parkway'] = $this->Home_m->get_random_parkway();
        $this->_data['list_member'] = $this->Home_m->get_random_member(6,0,TRUE);
        $this->_data['actualite'] = $this->Home_m->get_random_actualite();
        $this->_data['new_members'] = $this->Home_m->get_random_member(20,0);
    }



}

class Admin_Controller extends MY_Controller {

    function Admin_Controller() {
        parent::MY_Controller();
        $header['page'] = "admin/header";
        $footer['page'] = "admin/footer";
        $sidebar['page'] = "admin/sidebar";
        $this->_data['sidebar'] = $sidebar;
        $this->_data['header'] = $header;
        $this->_data['footer'] = $footer;
        $this->_data['is_sidebar'] = true;
        $this->container = 'admin/container';
    }
   
}